import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'

import useVitePlugins from './vite-plugins'
import path from 'path';
// https://vitejs.dev/config/

export default defineConfig({
  plugins: useVitePlugins(),
  base: './',
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      "vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js"
    }
  },

  esbuild: {
    jsxFactory: 'h',
    jsxFragment: 'Fragment',
    jsxInject: "import { h } from 'vue';"
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: `@use "@/assets/styles/element/index.scss" as *;`,
      },
    },
  },
  // 开发环境代理配置，请更换target为后端服务器地址
  server: {
    host: true,
    proxy: {
      '/app': {
          target: 'http://172.16.1.71:8098',
          //target:'http://172.16.1.71:55940',
        // target: 'http://192.168.0.8:8080',
        //  target: 'http://yqcs.sa1.tunnelfrp.com',
        changeOrigin: true,
        rewrite: p => p.replace(/^\/app/, '')
      },

    }
  },
  build: {
    //outDir: path.resolve(__dirname, '/Areas/HT/Views/HTPS'),
    // 当生产环境浏览器版本较低时，请改为es2015
    // target: 'modules'
    target: ['es2015', 'chrome63'],

  }
})
